
/*
 * ControllerException class
 * This class is a custome Exception class extending from base class Exception. It is used to catch
 * exceptions thrown when the Window malfunctions or a power outage occurs in a Greenhouse Controls
 * object.
 * 
 * James Zhang
 * ID: 3069886
 * July 17, 2012
 */
//Imports the necessary java packages
import java.io.Serializable;

public class ControllerException extends Exception implements Serializable
{
    //Member which contains the error in string form
    String mistake;
    //Error code which represents the specific error which caused exception
    int code;

    /**
     * Default Constructor
     */
    public ControllerException()
    {
        //Calls super and sets the string mistake to default value of Error!
        super();
        mistake = "Error!";
    }

    /**
     * Constructor which takes a string for a custom error message and a error
     * code for the error
     *
     * @param err - The error in string form
     * @param errcode - The error code which represents that specific error
     */
    public ControllerException( String err, int errcode )
    {
        //Calls super and sets the members
        super( err );
        mistake = err;
        code = errcode;
    }

    /**
     * Accessor for mistake member
     *
     * @return - Returns mistake
     */
    public String getError()
    {
        return mistake;
    }

    /**
     * Accessor for error code
     *
     * @return - Returns the error code
     */
    public int getErrorCode()
    {
        return code;
    }
}
